﻿/*----------------------------------------------------------------
//  <copyright file="ISqlExecutor.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2022-12-01 11:52</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Entity
{
    #region "SQL语句执行功能接口"
    /// <summary>
    /// SQL语句执行功能接口
    /// </summary>
    /// <typeparam name="TEntity">实体类型</typeparam>
    /// <typeparam name="TKey">实体主键类型</typeparam>
    [MultipleDependency]
    public interface ISqlExecutor<TEntity, TKey> 
        where TEntity : IEntity<TKey>
    {
        #region "属性"
        #region "获取 数据库类型"
        /// <summary>
        /// 获取 数据库类型
        /// </summary>
        DatabaseType DatabaseType { get; }
        #endregion

        #endregion

        #region "方法"
        #region "查询指定SQL的结果集"
        /// <summary>
        /// 查询指定SQL的结果集
        /// </summary>
        /// <typeparam name="TResult">结果集类型</typeparam>
        /// <param name="sql">查询的SQL语句</param>
        /// <param name="param">SQL参数</param>
        /// <returns>结果集</returns>
        IEnumerable<TResult> FromSql<TResult>(string sql, object param = null);
        #endregion
        #region "执行指定的SQL语句"
        /// <summary>
        /// 执行指定的SQL语句
        /// </summary>
        /// <param name="sql">执行的SQL语句</param>
        /// <param name="param">SQL参数</param>
        /// <returns>操作影响的行数</returns>
        int ExecuteSqlCommand(string sql, object param = null);
        #endregion

        #endregion

    }
    #endregion

}
